﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Organizer.Server
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class WebService : IWebService
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        #region Movie_Wish
        public void Movie_Wish_Add(Model.Movie.Wish wish)
        {
            log.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name + " called");

            using (var db = new ServiceContext())
            {
                /*
                db.Movies_Wish.Add(wish);
                db.SaveChanges();
                */
            }
        }

        public IQueryable<Model.Movie.Wish> Movie_Wish_Select(string searchFor)
        {
            log.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name + " called");

            using (var db = new ServiceContext())
            {
                /*
                IQueryable<Model.Movie.Wish> wishes = (from w
                                 in db.Movies_Wish
                             where w.Name.Contains(searchFor)
                             select w);
                if (wishes != null)
                {
                    return wishes;
                }
                */
            }
            throw new KeyNotFoundException("Invalid id");
        }

        public void Movie_Wish_Update(Model.Movie.Wish wish)
        {
            log.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name + " called");

            using (var db = new ServiceContext())
            {
                /*
                Model.Movie.Wish fromDB = db.Movies_Wish.Single(wishDb => wishDb.WishId == wish.WishId);

                fromDB = wish;

                db.SaveChanges();
                */
            }
        }

        public void Movie_Wish_Delete(Model.Movie.Wish wish)
        {
            log.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name + " called");

            throw new NotImplementedException();
        }

        public Model.Movie.Wish Movie_Wish_Get(int id)
        {
            log.Trace(System.Reflection.MethodBase.GetCurrentMethod().Name + " called");

            using (var db = new ServiceContext())
            {
                /*
                Model.Movie.Wish wish = (from w
                                 in db.Movies_Wish
                             where w.WishId == id
                             select w).FirstOrDefault();
                if (wish != null)
                {
                    return wish;
                }
                throw new KeyNotFoundException("Invalid id");
                */
                return null;
            }
        }
        #endregion Movie_Wish
    }
}
